import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'layout',
    component: () => import('@/views/layout'),
    children: [
      {
        path: '', // 默认子路由
        name: 'home',
        component: () => import('@/views/home/index.vue')
      },
      {
        path: 'search',
        name: 'search',
        component: () => import('@/views/search/index.vue')
      },
      {
        path: 'order',
        name: 'order',
        component: () => import('@/views/order/index.vue')
      },
      {
        path: '/my',
        name: 'my',
        component: () => import('@/views/my')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/login-page.vue')
  },
  {
    path: '/card',
    name: 'card',
    component: () => import('@/views/card/index.vue')
  },
  {
    path: '/service',
    name: 'service',
    component: () => import('@/views/service/index.vue')
  },
  {
    path: '/balance',
    name: 'balance',
    component: () => import('@/views/balance/index.vue')
  },
  {
    path: '/food',
    name: 'food',
    component: () => import('@/views/food')
  },
  {
    path: '/profile/:id',
    name: 'profile',
    component: () => import('@/views/profile')
  },
  {
    path: '/card',
    name: 'card',
    component: () => import('@/views/card/index.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
